package bishiqinagxun;
import java.util.*;
public class Test1 {
    //笔试强训 day28 第一题  游游的重组偶数

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int q = in.nextInt();
        while(q-- > 0) {
            int x = in.nextInt();
            String str  = String.valueOf(x);
            char[] ch = str.toCharArray();
            int n = ch.length;
            for(int i = n-1; i >= 0; i--) {  //不能有前导0  所以倒过来遍历
                if((ch[i] - '0' )% 2 == 0) {
                    //交换
                    swap(ch,i,n-1);
                    break;
                }
            }
            if((ch[n-1] - '0') % 2 == 0) {
                System.out.println(ch);
            }else {
                System.out.println(-1);
            }
        }
    }
    private static void swap(char[] ch,int i,int n) {
        char tmp = ch[i];
        ch[i] = ch[n];
        ch[n] = tmp;
    }
}
